package com.itheima.mapper;

import com.itheima.pojo.Brand;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface BrandMapper {


    /**
     * 查询所有
     * @return
     */
    @Select("select * from tb_brand;")
    @ResultMap("brandResultMap")
    List<Brand>selectAll();

    /**
     * 插入数据
     * @param brand
     * @return
     */
    @Insert("insert into tb_brand (id,brand_name, company_name, ordered, description, status) values (null,#{brandName},#{companyName},#{ordered},#{description},#{status});")
    void insert(Brand brand);


    /**
     * 批量删除
     * @param ids
     */
    void deleteByIds(@Param("ids") int []ids);

    /**
     * 查询当前页的数据
     * @param begin
     * @param pageSize
     * @return
     */
    @Select("select * from tb_brand limit #{begin},#{pageSize}")
    @ResultMap("brandResultMap")
    List<Brand>selectByPage(@Param("begin") int begin,@Param("pageSize") int pageSize);

    /**
     * 查询表中所有信息
     * @return
     */
    @Select("select count(*) from tb_brand;")
    int selectAllCount();


}
